﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;


namespace PRE
{
    public partial class FrmMain : RibbonForm
    {
        public FrmMain()
        {
            InitializeComponent();

        }

        private void iExit_ItemClick(object sender, ItemClickEventArgs e)
        {
            Application.Exit();
        }

        private void btdangky_ItemClick(object sender, ItemClickEventArgs e)
        {
            //foreach (var x in MdiChildren) if (x is catalog.Frmdangkytaikhoan) return;
            //var frm = new catalog.Frmdangkytaikhoan() { MdiParent = this };
            catalog.Frmdangkytaikhoan frm = new catalog.Frmdangkytaikhoan();
            //imagedesktop.Visible = false;
            frm.ShowDialog();
        }

        private void btchucvu_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmChucVu) return;
            var frm = new catalog.FrmChucVu() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void btphongban_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmPhongBan) return;
            var frm = new catalog.FrmPhongBan() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void btnhanvien_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmNhanVien) return;
            var frm = new catalog.FrmNhanVien() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void btkhachhang_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmKhachHang) return;
            var frm = new catalog.FrmKhachHang() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void bthopdong_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmHopDongDien) return;
            var frm = new catalog.FrmHopDongDien() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void btdienke_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmDienKe) return;
            var frm = new catalog.FrmDienKe() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void btchisodienke_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmChiSoDienKe) return;
            var frm = new catalog.FrmChiSoDienKe() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void bthoadon_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmHoaDonTienDien) return;
            var frm = new catalog.FrmHoaDonTienDien() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void btmucdichsudung_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmMucDichSuDung) return;
            var frm = new catalog.FrmMucDichSuDung() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void barButtonItem1_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmTrangThai) return;
            var frm = new catalog.FrmTrangThai() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        private void barButtonItem2_ItemClick(object sender, ItemClickEventArgs e)
        {

            foreach (var frm in MdiChildren) frm.Close();
            imagedesktop.Visible = true;
        }

        private void btdangnhap_ItemClick(object sender, ItemClickEventArgs e)
        {
            //foreach (var x in MdiChildren) if (x is catalog.FrmDangNhap) return;
            //var frm = new catalog.FrmDangNhap() { MdiParent = this };
            catalog.FrmDangNhap frm = new catalog.FrmDangNhap();
           // frm.Show();
            
            if (frm.ShowDialog() == DialogResult.OK)
            {lbtennhanvien.Text = _tennhanvien;
                enablemenu();
                
            }
        }

        private void bttaikhoan_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is catalog.FrmTaiKhoan)  return;
            var frm = new catalog.FrmTaiKhoan() { MdiParent = this };

            frm.Show();
        }

        private void barButtonItem3_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is Thongke.FrmThongkeKHtheotrangthaiHD) return;
            var frm = new Thongke.FrmThongkeKHtheotrangthaiHD() { MdiParent = this };

            frm.Show();
        }
        public void enablemenu(Boolean istrue = true)
        {
            btchisodienke.Enabled = istrue;
            btchucvu.Enabled = istrue;
            btdangky.Enabled = !istrue;
            btdangnhap.Enabled = !istrue;
            btdangxuat.Enabled = istrue;
            btdienke.Enabled = istrue;
            bthoadon.Enabled = istrue;
            bthopdong.Enabled = istrue;
            btkhachhang.Enabled = istrue;
            btmucdichsudung.Enabled = istrue;
            btnhanvien.Enabled = istrue;
            btphongban.Enabled = istrue;
            bttaikhoan.Enabled = istrue;
            bt_TK_KH_trangthai.Enabled = istrue;
            bttrangthai.Enabled = istrue;
            bttkKH_trangthaihoadon.Enabled = istrue;
            btTKhoadontheoThang.Enabled = istrue;

        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            enablemenu(false);
        }

        private void btdangxuat_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var frm in MdiChildren) frm.Close();
            imagedesktop.Visible = true;
            enablemenu(false);
        }

        private void barButtonItem4_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is Thongke.FrmTK_KH_chuadongtien) return;
            var frm = new Thongke.FrmTK_KH_chuadongtien() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

        public string _tennhanvien;
        public string _manhanvien="";

        private void imagedesktop_EditValueChanged(object sender, EventArgs e)
        {

        }

        private void btTKhoadontheoThang_ItemClick(object sender, ItemClickEventArgs e)
        {
            foreach (var x in MdiChildren) if (x is Thongke.FrmTK_hoadon_thang) return;
            var frm = new Thongke.FrmTK_hoadon_thang() { MdiParent = this };
            imagedesktop.Visible = false;
            frm.Show();
        }

 
    }
}